//
//  MYQRCoderViewController.m
//  beautyLamp
//
//  Created by Tam Kwok To Michael on 2017/9/22.
//  Copyright © 2017年 Tam Kwok To Michael. All rights reserved.
//

#import "MYQRCoderViewController.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import "BLHeader.h"
#import "MyQRCodeNet.h"

@interface MYQRCoderViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *telLabel;
@property (weak, nonatomic) IBOutlet UIImageView *codeImageView;

@end

@implementation MYQRCoderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
    [self getCode];
}

- (void)setupUI {
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.title = @"我的二维码";
    NSString *url = [[NSUserDefaults standardUserDefaults] objectForKey:USERIMG];
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"icon"]];
    NSString *codeString = [[NSUserDefaults standardUserDefaults] objectForKey:USERQRCODE];
    [self.codeImageView sd_setImageWithURL:[NSURL URLWithString:codeString]];
    NSString *userName = [[NSUserDefaults standardUserDefaults] objectForKey:USERNAME];
    self.nameLabel.text = userName;
    self.telLabel.text = [[NSUserDefaults standardUserDefaults] objectForKey:USERTEL];
}

- (void)getCode {
    [MyQRCodeNet getMyQRCode:^(id result, NSError *error) {
        if (result) {
            NSString *code_url = result;
            [self.codeImageView sd_setImageWithURL:[NSURL URLWithString:code_url]];
        }
    }];
}
@end
